// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SystemException.java

package com.iphaeton.exception;

import java.io.PrintStream;
import java.io.PrintWriter;

public class SystemException extends Exception
{

    public SystemException(String s, Throwable t)
    {
        super(s);
        mRootCause = null;
        mRootCause = t;
    }

    public SystemException(Throwable t)
    {
        mRootCause = null;
        mRootCause = t;
    }

    public SystemException(String s)
    {
        super(s);
        mRootCause = null;
    }

    public SystemException()
    {
        mRootCause = null;
    }

    public Throwable getRootCause()
    {
        return mRootCause;
    }

    public void printStackTrace()
    {
        super.printStackTrace();
        if(mRootCause != null)
        {
            System.out.println("---------- ROOT CAUSE ----------");
            mRootCause.printStackTrace();
        }
    }

    public void printStackTrace(PrintStream s)
    {
        super.printStackTrace(s);
        if(mRootCause != null)
        {
            s.println("--- ROOT CAUSE ---");
            mRootCause.printStackTrace(s);
        }
    }

    public void printStackTrace(PrintWriter s)
    {
        super.printStackTrace(s);
        if(mRootCause != null)
        {
            s.println("--- ROOT CAUSE ---");
            mRootCause.printStackTrace(s);
        }
    }

    public String getRootCauseMessage()
    {
        String rcmessage = null;
        if(getRootCause() != null)
        {
            if(getRootCause().getCause() != null)
                rcmessage = getRootCause().getCause().getMessage();
            rcmessage = rcmessage != null ? rcmessage : getRootCause().getMessage();
            rcmessage = rcmessage != null ? rcmessage : super.getMessage();
            rcmessage = rcmessage != null ? rcmessage : "NONE";
        }
        return rcmessage;
    }

    private Throwable mRootCause;
}
